package util

import (
	"math"
)

func FormatAmount(val float64) float64 {
	l, r := math.Modf(val)
	p := int(math.Trunc(r * math.Pow10(5)))
	if p%int(math.Pow10(3)) > 0 {
		r = float64(int(math.Trunc(float64(p)/math.Pow10(3)))+1) / math.Pow10(2)
	} else {
		r = float64(p) / math.Pow10(5)
	}
	return float64(l) + r
}
